package com.project.shangqi.service.impl;

import com.project.shangqi.dto.UnidResult;
import com.project.shangqi.entity.VehicleColumn;
import com.project.shangqi.mapper.VehicleColumnMapper;
import com.project.shangqi.service.VehicleColumnService;
import com.project.shangqi.util.HttpUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VehicleColumnServiceImpl implements VehicleColumnService {

    @Resource
    private VehicleColumnMapper vehicleColumnMapper;

    @Override
    public List<UnidResult> getFromUrl(String token, String url, Integer timeout) throws Exception {
        HttpUtil httpUtil = new HttpUtil(url, token, timeout);
        List<UnidResult> result = (List<UnidResult>) httpUtil.getUrl(UnidResult.class, 2);
        return result;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void insert(VehicleColumn entity) throws Exception {
        vehicleColumnMapper.insertSelective(entity);
    }
}
